// 2025/07/27
// Author: Forever
#include <bits/stdc++.h>
using namespace std;

int n, m, q, a[100005], mid, sum[400005], lazy[400005], len[400005];

struct {
    bool type;
    int l, r;
} input[100005];

void build(int p, int l, int r)
{
    if (l == r) {
        sum[p] = a[l] > mid, len[p] = 1;
        return;
    }
    int mid2 = (l + r) / 2;
    build(p * 2, l, mid2);
    build(p * 2 + 1, mid2 + 1, r);
    sum[p] = sum[p * 2] + sum[p * 2 + 1], len[p] = r - l + 1, lazy[p] = 0;
}

void pushdown(int p)
{
    if (lazy[p] == 1) {
        lazy[p * 2] = lazy[p * 2 + 1] = 1;
        sum[p * 2] = len[p * 2];
        sum[p * 2 + 1] = len[p * 2 + 1];
    } else if (lazy[p] == 2) {
        lazy[p * 2] = lazy[p * 2 + 1] = 2;
        sum[p * 2] = 0;
        sum[p * 2 + 1] = 0;
    }
    lazy[p] = 0;
}

void update(int p, int l, int r, int x, int y, int v)
{
    pushdown(p);
    if (x <= l && r <= y) {
        lazy[p] = v;
        if (v == 1)
            sum[p] = len[p];
        else
            sum[p] = 0;
        return;
    }
    int mid = (l + r) / 2;
    if (x <= mid)
        update(p * 2, l, mid, x, y, v);
    if (y > mid)
        update(p * 2 + 1, mid + 1, r, x, y, v);
    sum[p] = sum[p * 2] + sum[p * 2 + 1];
}

int query(int p, int l, int r, int x, int y)
{
    pushdown(p);
    if (x <= l && r <= y)
        return sum[p];
    int mid = (l + r) / 2, res = 0;
    if (x <= mid)
        res += query(p * 2, l, mid, x, y);
    if (y > mid)
        res += query(p * 2 + 1, mid + 1, r, x, y);
    return res;
}

bool check()
{
    build(1, 1, n);
    for (int i = 1; i <= m; i++) {
        int lo = input[i].r - input[i].l + 1;
        int res1 = query(1, 1, n, input[i].l, input[i].r), res0 = lo - res1;
        if (res1 == 0 || res0 == 0 || res1 == lo || res0 == lo)
            continue;
        if (input[i].type) {
            update(1, 1, n, input[i].l, input[i].l + res1 - 1, 1);
            update(1, 1, n, input[i].l + res1, input[i].r, 2);
        } else {
            update(1, 1, n, input[i].l, input[i].l + res0 - 1, 2);
            update(1, 1, n, input[i].l + res0, input[i].r, 1);
        }
    }
    return query(1, 1, n, q, q);
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= m; i++)
        cin >> input[i].type >> input[i].l >> input[i].r;
    cin >> q;
    int l = 1, r = n;
    while (l <= r) {
        mid = (l + r) / 2;
        if (check())
            l = mid + 1;
        else
            r = mid - 1;
    }
    cout << l << endl;
    return 0;
}